
<?php
header('Content-type:text/html;charset=utf-8');
if(!$d= @mysql_connect('127.0.0.1','root','')){
	echo mysql_errno();
	exit;
}
if(!mysql_select_db('hdc50')){
	echo mysql_errno();
	exit;
}

mysql_query('set names utf8');

// $d = mysql_query("insert into stu set username='小苹果',age='1992-9-2',sex=1");

// var_dump($d);



$result = mysql_query("select * from stu");

while ($row = mysql_fetch_array($result,MYSQL_BOTH)) {
		$rows [] =$row;
	}

?>

<table border="1">
	<tr>
		<td>ID</td>
		<td>学生名称</td>
		<td>生日</td>
		<td>性别</td>
	</tr>

	<?php foreach ($rows as $f): ?>
		<tr>
		<td><?php echo $f['id']?></td>
		<td><?php echo $f['username']?></td>
		<td><?php echo $f['age']?></td>
		<td><?php echo $f['sex']?></td>
	</tr>

	<?php endforeach ?>
	
</table>